import request from '@/sheep/request';

interface SocialApiParams {
  type: string;
  code?: string;
  state?: string;
  openid?: string;
  // Add other parameters as needed
}

const SocialApi = {
  // 获得社交用户
  getSocialUser: (type: string): Promise<any> => {
    return request({
      url: '/member/social-user/get',
      method: 'GET',
      params: {
        type
      },
      custom: {
        showLoading: false,
      },
    });
  },
  // 社交绑定
  socialBind: (type: string, code: string, state: string): Promise<any> => {
    return request({
      url: '/member/social-user/bind',
      method: 'POST',
      data: {
        type,
        code,
        state
      },
      custom: {
        showSuccess: true,
        loadingMsg: '绑定中',
        successMsg: '绑定成功',
      },
    });
  },
  // 社交解绑
  socialUnbind: (type: string, openid: string): Promise<any> => {
    return request({
      url: '/member/social-user/unbind',
      method: 'DELETE',
      data: {
        type,
        openid
      },
      custom: {
        showLoading: false,
        loadingMsg: '解除绑定',
        successMsg: '解绑成功',
      },
    });
  },
};

export default SocialApi;
